/**
 * Alipay.com Inc.
 * <p>
 * Copyright (c) 2004-2014 All Rights Reserved.
 */

package com.work.cos.util.thirdpay.alipay.config;


import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;

import java.io.IOException;
import java.util.Properties;

/**
 * 支付宝服务窗环境常量（demo中常量只是参考，需要修改成自己的常量值）
 *
 * @author taixu.zqq
 * @version $Id: AlipayServiceConstants.java, v 0.1 2014年7月24日 下午4:33:49 taixu.zqq Exp $
 */
public class AlipayServiceEnvConstants {


    public static Properties readProperties(String path) {
        Properties p = new Properties();
        try {
            p.load(AlipayServiceEnvConstants.class.getResourceAsStream(path));
        } catch (IOException e) {
            e.printStackTrace();
        }

        return p;
    }

    /**
     * 获取config的value
     * @param key
     * @return
     */
    public static String get(String key) {
        return getProperty(config, key);
    }

    /**
     * 获取配置文件中的属性
     * @param properties
     * @param key
     * @return
     */
    public static String getProperty(Properties properties, String key) {
        if (properties != null && StringUtils.isNotBlank(key)) {
            return properties.getProperty(key);
        } else {
            return null;
        }
    }

    public static final Properties config = readProperties("/conf/env.properties");

    public static final String notify_url = get("notify.url");

    /**支付宝公钥-从支付宝生活号详情页面获取*/
    public static final String ALIPAY_PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgl5gdS+hdEWiU25A/u4OvzcCqZ5Q9dMwVPrRHfV0+FFQydIbg83dmQVqSOtEl6toEmxyWDZeeYBO3vK/9dCu8xkiUVvD2sHsvQOOYxQxK09sbCzIVodEQoBRqCidMkPYruX76VQ+ysdPGiDwok2rahli3WWIsxg13+yl2owadDeZfR8kXK3DldMxiBq1Rsm6OaD7CnXTl6ikdymq83iMQYvURUsJysp6yFJ/eMO6MQadtYJmPpFiCQPtPC2Ut+MbdM5v73ByCZWnICy2Zl7gwriXE1JSxIgDZT/61sBCsC8+eh/yJVk/Y19dIzwov9CbAYhxoXJczKsXQwwB+KeAIQIDAQAB";

    /**签名编码-视支付宝服务窗要求*/
    public static final String SIGN_CHARSET = "GBK";

    /**字符编码-传递给支付宝的数据编码*/
    public static final String CHARSET = "utf-8";

    /**签名类型-视支付宝服务窗要求*/
    public static final String SIGN_TYPE = "RSA2";

    /**开发者账号PID*/
    public static final String PARTNER = "";

    /** 服务窗appId  */
    //TODO !!!! 注：该appId必须设为开发者自己的生活号id  
    public static final String APP_ID = "2017022805948445";

    //TODO !!!! 注：该私钥为测试账号私钥  开发者必须设置自己的私钥 , 否则会存在安全隐患 
    public static final String PRIVATE_KEY = "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDLea9DIzZTdSuaq+6ATcKAST8BMUWhRXc7107mZcHd2TaE76KUDZFY1JF+GNilh2+BLgSHY4z5EqVO6cusPGmjrpP9gKTd9CXY1qdwgK8Drk1D4e4LB2ReXO2lBQqDmME9kfjg36IJbaVATFvjitVFnz3NjcUPOKfB2iiOT6U8TwKfoFHKQYSXPaWzcjMtbBCeSG9ZLmn/QtAfzflikFFi5W3FgZjV6r98X06RqLFWTfSzsTFMxoqCJDccb+11uE6LC8D4nG7Ovll54v/C+1Rmc8TZEf7rzj5t3VfaM8ISeVhxEk5P7eFljsJebQs0Unv/uz/2NJG6FtLPHlQrIsZJAgMBAAECggEABR3aOmX4R8D6h7krFi7eZTtySiVjCtskVGzlnwWQCnQb2tvryq1Mql8uCW22hPMS6rytgHoQYXMGlSVr6bjbLzKEpitF+g7ZpMpBC6Mww3bumnZj9gMJkxXjI/MsgIKm2VWCXKVC/dmz/hntdZtYIZgPhcu62Ncj4MwLmQiHryyB6naWfhm/K9iHo8Tjs+1jFmAfZ3kAsGFwkLjZT4AwoEc38URBkcKZvVncaKNg2g0Fl+ranjNOIW1FGQFcdYTvZTSERf41OvAga/1ekPk327IUcXZlFaCj4FdqaTdmX8lddWwJ6DSzH+5rERW30T6hVA1GuQh1NGiuBNtnSUJ3AQKBgQD82s+o74q1izllHe/NdCb+uSWEvOjt1xx37Pric7knM6C/sH+4tmCE8357jm0kkdiqxXnjIYIWTVC+JgG++UT3G1VhvhmGfuj9TiFhj/Bnyz47yqtCYRmB93MrJhFUSjUG932LxMDXjh5mP3gqi/jtTkDg5I3Mbu8Oo7f1BLxrnQKBgQDOAaFJrfBlyjLvI7fqkVVg2DXm8fSu5LZaWSEQqkIE1JLv3usQ5bomqKEsGaJ2zD6qGGYigpSOz6M8VlvvSAowlGLhUvrzUXya6P4dNs3m30Hw5PNjrxkpq1cbNRiM+gQf9GCrg++gu9wCuO6GGa2pnc+wG7hxRoNZraoT3M6znQKBgHajvFfJvU2dO5rkRwYhf8J44M+9S5V9HxBuEvF51uA76yrGB8eFWxhGn4wdsbw86mqGKcCWklEgicgOUTdoAiHno1IvPg7LMUrZA/Sg8u3ggRzQ5TZKFQvULSeLvwnLn8HbEf8onEsHld/n29wqvOurkelzk8zeKDC4RLIkPLxJAoGAKeXY+NRAjWNHYq3ADRwL4kt3AwZ4vk1T7SItgGcwUC0vyUtsQZ6Hcq9fQEniagj2Qb/+ncwzDKycRXxG7G6Za/Hx/mPTGEOddSAn9qcbz3XewnC+M6r8EiZ/68+rs5hx2FHqi1elF+q9P2x/TpTQZivrfqTUqW0u78FLUwjYnV0CgYABLRAEhOg2FLJOaXdVkniLjkmgRM/LObr2DLBDmNgz07HADlvPQb2narmzi52k2eIqeUz4WF2FAAv8Cw+FxjstghZwVXVa5X04EBUK5tl2dyu4eqxFDbD8A6pXRx8bASh4inwt9QIlxiGU9q0BvvZEUGxlVahRqlJjahEqV9AsMg==";

    //TODO !!!! 注：该公钥为测试账号公钥  开发者必须设置自己的公钥 ,否则会存在安全隐患
    public static final String PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAy3mvQyM2U3UrmqvugE3CgEk/ATFFoUV3O9dO5mXB3dk2hO+ilA2RWNSRfhjYpYdvgS4Eh2OM+RKlTunLrDxpo66T/YCk3fQl2NancICvA65NQ+HuCwdkXlztpQUKg5jBPZH44N+iCW2lQExb44rVRZ89zY3FDzinwdoojk+lPE8Cn6BRykGElz2ls3IzLWwQnkhvWS5p/0LQH835YpBRYuVtxYGY1eq/fF9OkaixVk30s7ExTMaKgiQ3HG/tdbhOiwvA+Jxuzr5ZeeL/wvtUZnPE2RH+684+bd1X2jPCEnlYcRJOT+3hZY7CXm0LNFJ7/7s/9jSRuhbSzx5UKyLGSQIDAQAB";
    /**支付宝网关*/
    public static final String ALIPAY_GATEWAY = "https://openapi.alipay.com/gateway.do";

    /**授权访问令牌的授权类型*/
    public static final String GRANT_TYPE = "authorization_code";
}